package jdklearn.jdk动态代理;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * create at 2018/10/23
 * author: suveng
 * email: suveng@163.com
 **/
public class MyInvocation implements InvocationHandler {
    public Object object;

    public MyInvocation(Object object) {
        this.object = object;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        System.out.println("------插入前置通知代码-------------");
        // 执行相应的目标方法
        Object rs = method.invoke(object,args);
        System.out.println("------插入后置处理代码-------------");
        return rs;
    }
}
